﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wsitech.BLL;
using Wsitech.Model;
using Wsitech.Utility;

public partial class Backend_Job : BackendPageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bindPosition();
        }
    }

   

    //绑定职位信息
    private void bindPosition()
    {
        int count = 0;
        repMain.DataSource = PositionInfoBLL.Instance.GetPagedList(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, ref count);
        repMain.DataBind();

        AspNetPager1.RecordCount = count;
    }

    //职位信息的启用和禁用
    protected void repMain_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        LinkButton lbtnEnable = (LinkButton)e.Item.FindControl("lbtnEnable");
        LinkButton lbtnDisable = (LinkButton)e.Item.FindControl("lbtnDisable");

        //显示和隐藏启用与禁用按钮
        PositionInfo info = e.Item.DataItem as PositionInfo;
        if (info != null)
        {
            if (info.State == (int)UtilityEnum.State.Enable)
            {
                lbtnEnable.Visible = false;
            }
            if (info.State == (int)UtilityEnum.State.Disable)
            {
                lbtnDisable.Visible = false;
            }
        }
    }
    protected void repMain_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        string jobid = e.CommandArgument.ToString();
        switch (e.CommandName)
        {
            case "Enable":
                PositionInfoBLL.Instance.ChangeState(jobid, UtilityEnum.State.Enable);
                break;
            case "Disable":
                PositionInfoBLL.Instance.ChangeState(jobid, UtilityEnum.State.Disable);
                break;
            default:
                break;
        }
        Response.Redirect(Request.Url.ToString());
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bindPosition();
    }

    
}